package com.zer0.tga.tile;

import java.util.List;

import com.zer0.tga.art.ArtArchive;
import com.zer0.tga.art.Screen;
import com.zer0.tga.entity.Entity;
import com.zer0.tga.level.Level;
import com.zer0.tga.math.BoundingBox;
import com.zer0.tga.math.BoundingBoxOwner;
import com.zer0.tga.math.Box;
import com.zer0.tga.math.Coordinate;
import com.zer0.tga.math.Direction;

public abstract class Tile implements BoundingBoxOwner {

    public static final int HEIGHT = 64;
    public static final int WIDTH = 64;

    public Level level;
    public Coordinate position = new Coordinate();
  //  public int image;
	
    public Tile()
    {
    	
    }
	
	public Tile(Level level, double x, double y) {
		// TODO Auto-generated constructor stub
		init(level,x,y);
	}


	
	//    public int minimapColor;

	    public void init(Level level, double x, double y) {
	        this.level = level;
	        this.position.x = x;
	        this.position.y = y;
	    }

	    public boolean canPass(Entity e) {
	        return true;
	    }

	
	    public void render(Screen screen) {
	        screen.draw(ArtArchive.grassTile[0][0], position.x * Tile.WIDTH, position.y * Tile.HEIGHT); /*RandNum.getRandNum(0, 1)*/
	    }
	    
	    public void addBoundingBoxToList(List<BoundingBox> list, Entity e) {
	        if (canPass(e))
	        	return;

	        Box b = new Box( position.x * Tile.WIDTH, position.y * Tile.HEIGHT, (position.x + 1) * Tile.WIDTH, (position.y + 1) * Tile.HEIGHT);
	        list.add(new BoundingBox(this,b));
	    }

	    public boolean handleCollision(Entity entity) 
	    {
	       	System.out.println("These collided: " + this.getClass().getSimpleName() + position.x + " " +position.y +" and " + entity.getClass().getSimpleName());
	       	// if an entity collides with a wall, it's made so it collides with itself
	       	// a trick to bypass walls are not entites fact.
	       //	entity.collision(entity);
	       	
	       	return false;
	    }

	    public void hurt(Entity e)
	    {
	    	
	    }

		public void setSide(Direction side) {
			// TODO Auto-generated method stub
			
		}

		public void render2(Screen screen) {
			// TODO Auto-generated method stub
			
		}

	}